home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Sample Code / Snippets / Sound / EasyPlayRecord / EasyPlayRecord.c next >
Encoding:
C/C++ Source or Header  |  1995-02-11  |  1.2 KB  |  68 lines  |  [TEXT/MPS ]

  1. #include    <Quickdraw.h>
  2. #include    <Windows.h>
  3. #include    <dialogs.h>
  4. #include    <OSEvents.h>
  5. #include    <Memory.h>
  6. #include    <StandardFile.h>
  7. #include    <Sound.h>
  8. #include    <SoundInput.h>
  9. #include    <OSUtils.h>
  10.  
  11. #define    TRUE            0xFF
  12. #define    FALSE            0
  13.  
  14. #ifdef powerc
  15.    QDGlobals    qd;
  16. #endif
  17.  
  18.  
  19. main()
  20. {
  21.     Point                where = {20,20};
  22.     Point                whereto = {100,100};
  23.     OSErr                err;
  24.     StandardFileReply    reply;
  25.     short                refnum;
  26.     Handle                SNDHand;
  27.     SndChannelPtr        chan;
  28.         
  29.     InitGraf(&qd.thePort);
  30.     FlushEvents(everyEvent, 0);
  31.     InitWindows();
  32.     InitDialogs(nil);
  33.     InitCursor();
  34.     
  35.     StandardGetFile (nil, -1, nil, &reply);
  36.  
  37.     err = HOpen(reply.sfFile.vRefNum, reply.sfFile.parID, reply.sfFile.name, fsRdPerm, &refnum);
  38.     
  39.     if (err != noErr)
  40.       Debugger();
  41.     
  42.     err = SndStartFilePlay (nil, refnum, 0, 74000, nil, nil, nil, TRUE);
  43.     if (err != noErr)
  44.         Debugger();
  45.         
  46.     SNDHand = NewHandle (0xc9000);
  47.     if (MemError() != noErr || SNDHand == nil)
  48.         Debugger();
  49.  
  50.     err = SndRecord (nil, whereto, siBestQuality, &SNDHand);
  51.     if (err != noErr)
  52.         Debugger();
  53.         
  54.     FSClose (refnum);
  55.  
  56.     chan = nil;
  57.     err = SndNewChannel (&chan, 0, 0, nil);
  58.     if (err != noErr)
  59.         Debugger();
  60.     
  61.     err = SndPlay (chan, SNDHand, FALSE);
  62.     if (err != noErr)
  63.         Debugger();
  64.  
  65.     err = SndDisposeChannel (chan,FALSE);
  66.     if (err != noErr)
  67.         Debugger();
  68. }